home *** CD-ROM | disk | FTP | other *** search
Text File | 1994-06-26 | 1.4 KB | 67 lines | [TEXT/MPS ] |
- /*
- File: CPlusRuntime.cp
-
- Contains: Implementation of C++ Runtime methods so we can avoid
- linking the application with CPlusLib.o and StdCLib.o
- which contain lots of extra baggage. An important part
- of this file is to make “new” allocate objects using
- NewPtr() instead of malloc(), which has a nasty memory
- leak (some might call it a design decision) in MPW C.
- We could just define malloc() here, but that still keeps
- alot of strange, UNIX-esque routines around.
-
- Written by: Dave Falkenburg
-
- Copyright: © 1993-94 by Dave Falkenburg, all rights reserved.
-
- Change History (most recent first):
-
- */
-
- #include <Memory.h>
- #include <stddef.h> // for size_t
-
- #include "Exceptions.h"
-
- #ifdef MPW
-
- // MPW C++ calls the following C function
- // if a pure virtual method is called at runtime
- //
- // We provide our own version here to avoid linking in
- // the entire CPlusLib.o. It saves some space.
-
- extern "C"
- {
- void __pure_virtual_called(void);
- }
-
- void
- __pure_virtual_called(void)
- {
- DebugStr((ConstStr255Param) "\ppure virtual called.");
- ExitToShell();
- }
-
- #endif
-
-
- void * operator new (size_t objectSize);
- void operator delete (void *objectToDelete);
-
-
- void *
- operator new (size_t objectSize)
- {
- void *newObject = NewPtr(objectSize);
- return(newObject);
- }
-
-
- void
- operator delete (void *objectToDelete)
- {
- if (objectToDelete)
- DisposePtr((Ptr) objectToDelete);
- }
-